﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Reflection;

namespace PSE.Framework.Communication.Spb.Common
{
    public class Legacy
    {
        private object _legacy;
        private System.Type _legacyType;
        private CultureInfo _info;

        public Legacy()
        {
            this._legacyType = System.Type.GetTypeFromCLSID(new Guid("80225993-2559-473F-B1C9-E4D0F42B35CC"));
            this._legacy = System.Activator.CreateInstance(this._legacyType);
            this._info = CultureInfo.CurrentCulture;
        }

        public object Execute(string name, object[] args)
        {
            return this._legacyType.InvokeMember(
                name,
                System.Reflection.BindingFlags.InvokeMethod,
                null,
                this._legacy,
                args,
                this._info);         
        }

        public object Execute(string name, ref object[] args, ParameterModifier[] mods)
        {
            return this._legacyType.InvokeMember(
                name,
                System.Reflection.BindingFlags.InvokeMethod,
                null,
                this._legacy,
                args,
                mods,
                this._info,
                null);
        }
    }
}
